import {
  reqAddressInfo,
  reqTrade
} from "@/api"

const state = {
  addressInfo: [],
  orderInfo: {}
}

const mutations = {
  GETADDRESSINFO(state, addressInfo) {
    state.addressInfo = addressInfo
  },
  GETTRADE(state, orderInfo) {
    state.orderInfo = orderInfo
  }
}

const actions = {
  //获取收货地址
  async getAddressInfo({commit}) {
    let res = await reqAddressInfo()
    if (res.code == 200) {
      commit("GETADDRESSINFO", res.data)
    } else {
      return Promise.reject(new Error(res.message))
    }
  },
  //获取商品清单数据
  async getTrade({commit}) {
    let res = await reqTrade()
    if (res.code == 200) {
      commit("GETTRADE", res.data)
    } else {
      return Promise.reject(new Error(res.message))
    }
  },
//
}

const getters = {

}

export default {
  namespaced: true,
  state,
  actions,
  mutations,
  getters

}
